#ifndef __IAP_H
#define __IAP_H

#include "main.h"


#define SOH                     (0x01)  /* start of 128-byte data packet */
#define STX                     (0x02)  /* start of 1024-byte data packet */
#define EOT                     (0x04)  /* end of transmission */
#define ACK                     (0x06)  /* acknowledge */
#define NAK                     (0x15)  /* negative acknowledge */
#define CAN                      (0x18)  /* two of these in succession aborts transfer */
#define CRC16                   (0x43)  /* 'C' == 0x43, request 16-bit CRC */

uint8_t receiveOneByte(uint8_t *ch);
void sendOneByte(uint8_t ch);
uint16_t CRC16_XMODEM(uint8_t *puchMsg, uint16_t usDataLen);
uint16_t Cal_CRC16(const uint8_t* data, uint32_t size);
uint8_t startIap(void);

#endif

